package net.cn_su.sharpeyes.components;

import android.content.Context;
import android.content.res.Resources;
import android.graphics.Color;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import net.cn_su.sharpeyes.R;
import net.cn_su.sharpeyes.beans.Camera;

import org.androidannotations.annotations.EViewGroup;
import org.androidannotations.annotations.ViewById;

/**
 * Created by Overlord on 2016/08/11.
 * SingularityClub
 */
@EViewGroup(R.layout.item_camera)
public class CameraItem extends RelativeLayout {

    @ViewById
    protected ImageView imageView_icon;

    @ViewById
    protected TextView textView_camera_name, textView_camera_address;

    private Camera camera;

    public CameraItem(Context context) {
        super(context);
    }

    public Camera getCamera() {
        return camera;
    }

    public void setCamera(Camera camera) {
        this.camera = camera;
        textView_camera_name.setText(camera.getName());
        textView_camera_address.setText((camera.getAddress()));
        Resources resources = this.getResources();
        if(camera.isPlaying()){
            imageView_icon.setImageDrawable(resources.getDrawable(R.drawable.icon_suspended));
            textView_camera_name.setTextColor(resources.getColor(R.color.colorBlue));
            textView_camera_address.setTextColor(resources.getColor(R.color.colorBlue));
        }else{
            imageView_icon.setImageDrawable(resources.getDrawable(R.drawable.icon_play));
            textView_camera_name.setTextColor(resources.getColor(R.color.colorDefault));
            textView_camera_address.setTextColor(resources.getColor(R.color.colorDefault));
        }
    }
}
